def binary_serach(list,item):
    low = 0
    high = len(list)-1
    count = 0
    while low <= high:
        mid = (low+high)//2
        guess = list[mid]
        if guess == item:
            count+=1
            return guess,count
        if guess > item:
            count += 1
            high = mid-1
        else:
            count += 1
            low = mid+1
    return None

if __name__ == '__main__':
    list_length = 500000
    find_number = 5
    my_list = []
    for i in range(1,list_length):
        my_list.append(i)

    result = binary_serach(my_list,find_number)
    if result:
        print("找到的数是{}，找了{}次".format(result[0], result[1]))
    else:
        print("没找到")

